<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
	 <jsp:include page="/views/include.jsp"></jsp:include>
	 <script type="text/javascript">
		$.parser.onComplete = function(){
            $('body').css('visibility','visible');
            setTimeout(function(){
	        	$('#loading-mask').remove();
            },50);
        };
        
        function ajaxLoading(){ 
            $("<div class='datagrid-mask'></div>").css({display:"block",width:"100%",height:$(window).height()}).appendTo("body"); 
            $("<div class='datagrid-mask-msg'></div>").html("正在处理，请稍候。。。").appendTo("body").css({display:"block",left:($(document.body).outerWidth(true) - 190) / 2,top:($(window).height() - 45) / 2});
         }
        
        function ajaxLoadEnd(){ 
             $(".datagrid-mask").remove(); 
             $(".datagrid-mask-msg").remove();             
        }
        
        
		$(function() {
			$(window).resize(function(){
            	$('#mainlayout').layout('resize');
            });
			
			$('#dlg').dialog({
				onOpen:function(){
					$('#dt_excel').datagrid('resize');
				}
			});
			$('#dt_excel').datagrid({onDblClickRow:function dblClickRow(rowIndex,rowData){
				$('#update-excel-form')[0].reset();
				$('#update-excel-form').formid('loadit',rowData);
				$('#update-excel-dialog').dialog('setTitle','修改表信息').dialog('open');
			}});
		});
	
		function refresh(){
			$('#dt_excel').datagrid('loadData', {total:0,rows:[]});
			$('#dt_excel').datagrid('load',{});
		}
		
		function config() {
			var row = $('#dt_excel').datagrid('getSelected');
			if (row) {
				var shop_id = row["shop_id"];
				parent.addTab("隐射关系管理" , "<c:url value='/etl/mapping_mapping.tg' />?shopId=" + shop_id , "");
			} else {
				$.messager.show({
					title:'注意',
					msg:'请先选择数据，再进行修改。'
				});
			}
		}
		
		function mappedFormatter(value) {
			if(value){
				return "已配置";
			} else {
				return "未配置";
			}
		}
	</script>
</head>
	<body style="margin:0;padding:0;height:100%;overflow:hidden;background:#F2FBFF">
  			<div id="mainlayout" class="easyui-layout" fit="true">
			<div region="north" border="false">
				<div class="toolbar">
					<table cellpadding="0" cellspacing="0" style="width:95%;height=30px;">
						<tr>
							<td>
								<a href="javascript:refresh()" class="easyui-linkbutton" iconCls="icon-reload" plain="true">刷新</a>
								<a href="javascript:config()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">配置</a>
							</td>
						</tr>
					</table>
				</div>
			</div>
			
		<!-- 上传Excel Dialog  -->
		<div region="center" border="false">
			<table id="dt_excel" class="easyui-datagrid" url="<c:url value='excel_shops.tg'/>" fit="true" border="false" pagination="true" striped="true" fitColumns="true" singleSelect="true" rownumbers="true">
				<thead>
					<th field="shop_id" width="20" >分公司ID</th>
					<th field="shopName" width="20" >分公司名称</th>
					<th field="isMapped" formatter="mappedFormatter" width="20" >配置情况</th>
				</thead>
			</table>
		</div>
	</div>
</body>
</html>